package com.yonder.service.impl;

import com.yonder.dao.ItemsDao;
import com.yonder.pojo.Items;
import com.yonder.service.ItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ItemsServiceImpl implements ItemsService {
    @Autowired
    private ItemsDao itemsDao;
    @Override
    public List<Items> findAll() {
        return itemsDao.findAll();
    }

    @Override
    public Long addItems(Items items) {
        Long i = itemsDao.addItems(items);
        return i;
    }

    @Transactional
    @Override
    public void transfer(String fromName, String toName, Double price) {
        Long aLong = itemsDao.updateItems(fromName, price);
        Integer one = 10/0;
        Long aLong1 = itemsDao.updateItems(toName, -price);
    }
}
